package com.fdb.smcts.core.util;

import java.util.Scanner;


public class GeneratorBeanUtil {

	public static void main(String[] args) {
		
		 //generatorBean();   //无注释bean生成
		
		//generatorBeanHasAnno();  //有注释bean生成，输入字段带 “_”
		
		//generatorBeanHasAnno1();   //有注释bean生成，输入字段带 “_”，注释为“ @JsonProperty("") ”
		
		//generatorBeanHasAnno2();  //有注释bean生成，输入字段就是标准驼峰格式
		 
		 
		
		//生成ReqRepayConfirmBean类，变量名为reqQryRepayAmtBean的必输项校验语句，输入字段带 “_”
		//String varBeanName = "reqLoanResQryBean"; 
		//generatorRequiredWords(varBeanName);    
		 
		//生成ReqRepayConfirmBean类，变量名为reqQryRepayAmtBean的必输项校验语句，输入字段就是标准驼峰格式
		/*String varBeanName = "reqQryRepayAmtBean"; 
		generatorRequiredWords2(varBeanName);*/    
		
		/*String varStr = "requiredMap";
		generatorReqMapWords(varStr);*/    //生成MAP变量名为reqMap的语句
		
	}
	
	/**
	 * 输入要求：每行输入字段值中文意思，字段值
	 * 【最后多输入一行空行效果更好】
	 * 
	 * 样式：
	 *      真身id,user_identity
			银行客户号,bank_cusid
			贷款订单号,loan_listid
			贷款金额,loan_amount
			币种,cur_type
			
	 *	输出样式：
			@JSONField(name="user_identity")
			private String userIdentity;	//真身id
			
			@JSONField(name="bank_cusid")
			private String bankCusid;	//银行客户号
			
			@JSONField(name="loan_listid")
			private String loanListid;	//贷款订单号
			
			@JSONField(name="loan_amount")
			private String loanAmount;	//贷款金额
			
			@JSONField(name="cur_type")
			private String curType;	//币种
	 */
	public static void generatorBeanHasAnno() {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		while(!sc.hasNext("#")) {
			String str = sc.nextLine();
			String[] strings = str.split(",");
			String temp[] = strings[1].split("_");
			String result = null;
			if(temp.length == 3) {
				char[] a = temp[1].toCharArray();
				a[0]-=32;
				char[] b = temp[2].toCharArray();
				b[0]-=32;
				result = temp[0] + String.valueOf(a) + String.valueOf(b);
			} else if(temp.length == 2) {
				char[] uu = temp[1].toCharArray();
				uu[0] -=32;
				result = temp[0] + String.valueOf(uu);
			}else {
				result = strings[1];
			}
			
			System.out.println("@JSONField(name=\"" + result +"\"" + ")");
			System.out.println("private String "+ result + ";" + "\t" + "//" + strings[0]);
			System.out.println();
		}
		
	}
	
	public static void generatorBeanHasAnno1() {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		while(!sc.hasNext("#")) {
			String str = sc.nextLine();
			String[] strings = str.split(",");
			
			String temp[] = strings[0].split("_");
			String result = null;
			if(temp.length == 3) {
				char[] a = temp[1].toCharArray();
				a[0]-=32;
				char[] b = temp[2].toCharArray();
				b[0]-=32;
				result = temp[0] + String.valueOf(a) + String.valueOf(b);
			} else if(temp.length == 2) {
				char[] uu = temp[1].toCharArray();
				uu[0] -=32;
				result = temp[0] + String.valueOf(uu);
			}else {
				result = strings[0];
			}
			System.out.println("@JsonProperty(\"" + result +"\"" + ")");
			System.out.println("private String "+ result + ";" + "\t" + "//" + strings[1]);
			System.out.println();
		}
		
	}
	
	
	
	
	/**
	 * 输入要求：每行输入字段值中文意思，字段值
	 * 【最后多输入一行空行效果更好】
	 * 
	 *  【样式】：
			userId,真身id
			bankCusId,银行客户号
			applSeq,贷款订单号
			loanAmt,贷款金额
			curType,币种
			
	 *	【输出样式】：
	 *		@JSONField(name="userId")
			private String userId;	//真身id
		
			@JSONField(name="bankCusId")
			private String bankCusId;	//银行客户号
		
			@JSONField(name="applSeq")
			private String applSeq;	//贷款订单号
		
			@JSONField(name="loanAmt")
			private String loanAmt;	//贷款金额
		
			@JSONField(name="curType")
			private String curType;	//币种
			
	 */
	public static void generatorBeanHasAnno2() {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		while(!sc.hasNext("#")) {
			String str = sc.nextLine();
			String[] strings = str.split(",");
			System.out.println("@JSONField(name=\"" + strings[0] +"\"" + ")");
			System.out.println("private String "+ strings[0] + ";" + "\t" + "//" + strings[1]);
			System.out.println();
		}
		
	}
	
	
	
	/**
	  * 输入格式要求：一行一个字段值；建议【最后多输入一空行】
	  * 样式：
	  * 	user_identity
			bank_cusid
			loan_listid
			loan_amount
			cur_type
	  * 
	  * 输出样式：
			@JSONField(name="user_identity")
			private String userIdentity;
			
			@JSONField(name="bank_cusid")
			private String bankCusid;
			
			@JSONField(name="loan_listid")
			private String loanListid;
			
			@JSONField(name="loan_amount")
			private String loanAmount;
			
			@JSONField(name="cur_type")
			private String curType;
	  * 	
	 */
	public static void generatorBean() {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		while(!sc.hasNext("#")) {
			String str = sc.nextLine();
			System.out.println("@JSONField(name=\"" + str +"\"" + ")");
			
			String temp[] = str.split("_");
			String result = null;
			if(temp.length == 3) {
				char[] a = temp[1].toCharArray();
				a[0]-=32;
				char[] b = temp[2].toCharArray();
				b[0]-=32;
				result = temp[0] + String.valueOf(a) + String.valueOf(b);
			} else if(temp.length == 2) {
				char[] uu = temp[1].toCharArray();
				uu[0] -=32;
				result = temp[0] + String.valueOf(uu);
			} else {
				result = str;
			}
			System.out.println("private String "+ result + ";");
			System.out.println();
		}
	}
	
	
	/**
	 *  生成必填项校验语句
	 *  @param varBeanName 自己定义的bean对象变量名
	 * 【最后多输入一行空行效果更好】
	 *  
	 【输入样式】：
		          基金公司商户号,product_corp_spid
			真身id,user_identity
			
           【输出样式】：
		    InterfaceCheckUtils.getValue("product_corp_spid", "基金公司商户号", reqQryRepayAmtBean.getProductCorpSpid(), true);
			InterfaceCheckUtils.getValue("user_identity", "真身id", reqQryRepayAmtBean.getUserIdentity(), true);
	*/
	public static void generatorRequiredWords(String varBeanName) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		while(!sc.hasNext("#")) {
			String str = sc.nextLine();
			String[] strings = str.split(",");
			
			String temp[] = strings[1].split("_");
			String result = null;
			String result2 = null;
			if(temp.length == 3) {
				char[] a = temp[0].toCharArray();
				a[0]-=32;
				char[] b = temp[1].toCharArray();
				b[0]-=32;
				char[] c = temp[2].toCharArray();
				c[0]-=32;
				result = String.valueOf(a) + String.valueOf(b) + String.valueOf(c);
				
				result2 = temp[0] + String.valueOf(b) + String.valueOf(c);
			} else if(temp.length == 2) {
				char[] a = temp[0].toCharArray();
				a[0] -=32;
				char[] b = temp[1].toCharArray();
				b[0] -=32;
				result = String.valueOf(a) + String.valueOf(b);
				
				result2 = temp[0] + String.valueOf(b);
			}else {
				char[] Uu = strings[1].toCharArray();
				Uu[0]-=32;
				result = String.valueOf(Uu);
				
				result2 = strings[1];
			}
			System.out.println("InterfaceCheckUtils.getValue" + "(" + "\"" + result2 + "\"" + ", " + "\"" + strings[0] + "\"" + ", " + varBeanName + "." + "get" + result + "()" + ", " + "true" + ")" + ";");
		}
	}
	
	
	/**
	 *  使用InterfaceCheckUtils类中getValue方法进行必填项校验，生成必填项校验语句
	 *  @param varBeanName 自己定义的bean对象变量名
	 * 【最后多输入一行空行效果更好】
	 *  
	 【输入样式】：
			userIdentity,真身id
			loanListid,贷款订单号
			
           【输出样式】：
           InterfaceCheckUtils.getValue("userIdentity", "真身id", reqLoanResQryBean.getUserIdentity(), true);
		   InterfaceCheckUtils.getValue("loanListid", "贷款订单号", reqLoanResQryBean.getLoanListid(), true);
	*/
	public static void generatorRequiredWords2(String varBeanName) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		while(!sc.hasNext("#")) {
			String str = sc.nextLine();
			String[] strings = str.split(",");
			
			char[] Uu = strings[0].toCharArray();
			Uu[0]-=32;
			String result = String.valueOf(Uu);
			
			System.out.println("InterfaceCheckUtils.getValue" + "(" + "\"" + strings[0] + "\"" + ", " + "\"" + strings[1] + "\"" + ", " + varBeanName + "." + "get" + result + "()" + ", " + "true" + ")" + ";");
		}
	}
	
	
	/**
	 *  使用批量校验方法，需要封装map对象，生成对应的map封装语句
	 *  @param varMap 自己定义的MAP变量名 
	 * 【最后多输入一行空行效果更好】
	 * 
	 【输入样式】：     ////////////////////////////////////// 字段需要用逗号隔开
	 
		 	productCorpSpid,基金公司商户号
			userId,真身id

	 【输出样式】：
	 	    requiredMap.put("productCorpSpid", "基金公司商户号");
			requiredMap.put("userId", "真身id");
			
	 */
	public static void generatorReqMapWords(String varMap) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		while(!sc.hasNext("#")) {
			String str = sc.nextLine();
			String[] strings = str.split(",");
			
			System.out.println(varMap + ".put(" + "\"" + strings[0] + "\"" + ", \"" + strings[1] + "\");");
		}
	}
	
	
	
	
	
	
	
	
}
